<!DOCTYPE html>
<html class="x-admin-sm">

  <head>
    <meta charset="UTF-8">
    <title>{$list.set.webtitle}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    {load href="__XADMIN__/css/font.css" /}
    {load href="__XADMIN__/css/xadmin.css" /}
    {load href="__XADMIN__/js/jquery.min.js" /}
    {load href="__XADMIN__/lib/layui/layui.js" /}
    {load href="__XADMIN__/js/xadmin.js" /}
    {load href="__XADMIN__/js/cookie.js" /}
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- // 百度统计代码  -->
        <script>
          var _hmt = _hmt || [];
          (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?6f65eecea5e089dae94d6b9cffec3623";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
          })();
        </script>
    {block name="jscss"}{/block}
  </head>
  <body>
    <div class="x-body">
    	{block name="form"}{/block}
    </div>

    <script>
      //config的设置是全局的
      layui.config({
          base: "__XADMIN__/js/" //假设这是你存放拓展模块的根目录
      });
    </script>

    <script>

      layui.use(['form','cjgl'], function(){
        var form = layui.form
            cjgl = layui.cjgl;

        //监听提交
        form.on('submit(mysubmit)', function(data){
          $.ajax({
            url:"{$list.set.url}",
            type:"{$list.set.formpost}",
            data:data.field,
            dataType:'json',
            success:function(result){
              if(result.val == 1)
              {
                layer.msg(result.msg);
                //先得到当前iframe层的索引
                var index = parent.layer.getFrameIndex(window.name);
                //再执行关闭
                if(parent.layui.table){
                  parent.layui.table.reload('mytable');
                }
                parent.layer.close(index);
                parent.layer.msg(result.msg);
              }else{
                layer.msg(result.msg);
              }
            },
            error:function(xhr,status,error) {
              layer.msg('数据处理错误',{
                  icon: 2,
                  time: 2000 //2秒关闭（如果不配置，默认是3秒）
              });
            }
          });
          return false;
        });

        // 监听复选框
        form.on('checkbox', function(data){
          checkall = $(data.elem).attr('checkall');
          parentId = $(data.elem).parents("div").attr('id');
          fields = $(data.elem).attr('lay-filter');
          if(checkall=='p'){
            cjgl.checkboxAll(parentId,data.elem.checked);
          }else if(checkall=='c'){
            cjgl.checkboxParentList(parentId);
          }
          action = $(data.elem).attr('action');
          if(action == 'btmOnclick')
          {
            id = $(data.elem).attr('id');
            ischecked = data.elem.checked
            btmOnclick(id,ischecked);
          }
          if(fields=='auth')
          {
            id = $(data.elem).attr('id');
            checked = data.elem.checked;
            cjgl.checkedAuth(id,checked);
          }
        });
      });
  </script>
  {block name="myjs"}{/block}
  </body>
</html>
